/** 获取近半年时间段 */
export function getHalfYear() {
    var currentDate = new Date();
    var year = currentDate.getFullYear();
    var month = currentDate.getMonth() + 1;
    var sixMonthsAgo = new Date(year, month - 6, 1);
    var startDate = sixMonthsAgo.getFullYear() + '-' + (sixMonthsAgo.getMonth() + 1).toString().padStart(2, '0') + '-01';
    var endDate = currentDate.toISOString().slice(0, 10);
    return [startDate, endDate]
}


/** 获取近本月时间段 */
export function getCurrentMonth() {
    var currentDate = new Date();
    var year = currentDate.getFullYear();
    var month = currentDate.getMonth() + 1;
    // 获取本月1号的日期
    var firstDay = year + '-' + (month < 10 ? '0' + month : month) + '-01';
    // 获取本月最后一日的日期
    var lastDay = new Date(year, month, 0).toISOString().slice(0, 10);
    return [firstDay, lastDay]
}

/** 获取近全年时间段 */
export function getFullYear() {
    var currentDate = new Date(); // 获取当前日期
    var startDate = new Date(currentDate.getFullYear() - 1, currentDate.getMonth(), currentDate.getDate()); // 计算一年前的日期
    startDate = startDate.toISOString().slice(0, 10);
    var endDate = currentDate.toISOString().slice(0, 10); // 获取当前日期的字符串表示
    return [startDate, endDate]
}